package com.sayyi.demo.order.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sayyi.demo.order.entity.OrderTbl;
import com.sayyi.demo.order.service.IOrderTblService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author baomidou
 * @since 2022-03-01
 */
@RestController
@RequestMapping("/order/order-tbl")
public class OrderTblController {


    @Autowired
    private IOrderTblService orderTblService;

    /**
     * 分页查询
     * @return
     */
    @GetMapping("/page")
    public Page<OrderTbl> page() {
        // 分页参数
        Page<OrderTbl> page = new Page<>();
        page.setSize(10);
        page.setCurrent(1);
        // 查询条件
        QueryWrapper<OrderTbl> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("commodity_code", "default_code");

        return orderTblService.page(page, queryWrapper);
    }

    /**
     * 通过id获取
     * @param id
     * @return
     */
    @GetMapping("/getById")
    public OrderTbl getById(long id) {
        return orderTblService.getById(id);
    }
}
